package com.dfbz.dao;

import com.dfbz.entity.UserFocus;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface UserFocusDao extends Mapper<UserFocus> {

    @Select("select count(1) \n" +
            "from userfocus uf \n" +
            "where uf.user_id= #{loginUserId} and uf.user_focus_id= #{herId}")
    Integer byFollowHer(@Param("loginUserId") Integer loginUserId,@Param("herId") Integer herId);

    @Select("insert into userfocus(user_id,user_focus_id) values (#{loginUserId},#{herId})")
    void followHer(@Param("loginUserId") Integer loginUserId,@Param("herId") Integer herId);

    @Select("delete from userfocus where user_id= #{loginUserId} and user_focus_id=#{herId}")
    void unfollowHer(@Param("loginUserId") Integer loginUserId,@Param("herId") Integer herId);

    @Select("select user_focus_id \n" +
            "from userfocus uf \n" +
            "where uf.user_id=#{myId}")
    List<Integer> isFollowHer(@Param("myId") String myId);
}
